Hypothesis

Hypothesis is the property-based testing library for Python. With Hypothesis, you write tests which should pass for all inputs in whatever range you describe, and let Hypothesis randomly choose which of those inputs to check - including edge cases you might not have thought about. For example:

from hypothesis import given, strategies as st

@given(st.lists(st.integers()))
def test_matches_builtin(ls):
  assert sorted(ls) == my_sort(ls)

This randomized testing can catch bugs and edge cases that you didn't think of and wouldn't have found. In addition, when Hypothesis does find a bug, it doesn't just report any failing example — it reports the simplest possible one. This makes property-based tests a powerful tool for debugging, as well as testing.

Recent Articles

Introducing HypoFuzz
November 16, 2025
Liam DeVoe and Zac Hatfield-Dodds

If you're reading this blog, you probably know and hopefully love Hypothesis - we've been helping users write better test functions for over a decade now, which you can run with pytest, or unittest, or any other way you can call a Python function.

Getting called just like a traditional unit …

A Claude Code command for Hypothesis
November 01, 2025
Liam DeVoe, Muhammad Maaz, Zac Hatfield-Dodds, and Nicholas Carlini

We wrote a paper using Claude to autonomously write and run Hypothesis tests, and found real bugs in numpy, pandas, and other packages. We've extracted this to a Claude Code command for writing Hypothesis tests, which we're sharing today. We hope you find it …

Hypothesis is now thread-safe
August 07, 2025
Liam DeVoe

TL;DR: as of version 6.136.9, Hypothesis supports running the same test simultaneously from multiple threads.

Hypothesis has historically had the following thread-safety policy:

  • Running tests in multiple processes: fully supported.
  • Running separate tests in multiple threads: not officially supported, but mostly worked.
  • Running the same test in …

More articles from the Hypothesis blog →